<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分销商品订单列表</title>
    <link rel="stylesheet" href="https://www.layuicdn.com/layui-v2.5.6/css/layui.css" media="all">
    <style>
        .fxOrderList-container {
            padding: 20px;
        }

        td[data-field="imgUrl"] div,
        td[data-field="negativeImgUrl"] div {
            height: 120px;
        }

        .lay-form {
            padding: 20px;
        }
        .fxOrderList-container {
            background-color: #fff;
        }
        .bar {
            display: flex;
            justify-content: flex-start;
            align-items: flex-end;
        }
        .searchInput {
            display: flex;
            align-items: flex-end;
        }
        .searchInput input {
            width: 200px;
        }
        .searchInput .layui-form-label {
            padding: 9px 0;
        }
        .bar .layui-form-label {
            padding: 0;
            padding-bottom: 4px;
            text-align: left;
        }
        .bar .layui-inline {
            margin-right: 20px;
        }
        .layui-table img {
            max-width: 200px;
            object-fit: contain;
        }
        .layui-table-cell {
            height: auto;
        }
    </style>
</head>

<body>
<div class="fxOrderList-container">

    <!-- 搜索 -->
    <div class="searchInput">
        <form class="layui-form" action="" lay-filter="resets">
            <div class="layui-inline">
                <label class="layui-form-label">用户昵称：</label>
                <input class="layui-input" name="userName" placeholder="请输入客户昵称" autocomplete="off">
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">订单号：</label>
                <input class="layui-input" name="orderNo" placeholder="请输入订单号" autocomplete="off">
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">商品名称：</label>
                <input class="layui-input" name="distributionName" placeholder="请输入分销商品名称" autocomplete="off">
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">创建日期：</label>
                <input type="text" class="layui-input" id="test1" name="settleTimeStart" placeholder="请输入购买时间" autocomplete="off">
            </div>
            <button class="layui-btn" data-type="reload" lay-submit="" lay-filter="searchForm">搜索</button>
            <button class="layui-btn layui-btn-primary" data-type="reload" lay-submit="" lay-filter="reset">重置</button>
        </form>
    </div>

    <form class="layui-form">
        <!-- 筛选 -->
        <div class="layui-inline">
            <div class="layui-form-item" id="status" style="margin-bottom:0">
                <label class="layui-form-label" style="text-align:right; font-size:14px;padding: 9px 0;">结算状态：</label>
                <div class="layui-input-block" style="margin-left: 80px; margin-top: 16px;">
                    <select name="stop" lay-filter="select">
                        <option value="">全部</option>
                        <option value="30000">已支付</option>
                        <option value="20000">未支付</option>
                        <option value="40000">已关单</option>
                    </select>
                </div>
            </div>
        </div>

    </form>

    <table lay-filter="fxOrderListTable" class="layui-hide" id="fxOrderListTable"></table>
</div>

</body>


<!-- 操作 -->
<!-- <script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">查看详情</a>
</script> -->

<script src="https://www.layuicdn.com/layui-v2.5.6/layui.js"></script>
<script src="../utils.js"></script>
<script>
    layui.use(['table', 'form', 'jquery', "laydate"], function () {
        var table = layui.table,
            form = layui.form,
            laydate = layui.laydate,
            $ = layui.jquery;
        form.render();
        table.render({
            elem: '#fxOrderListTable'
            , url: window.baseUrl + '/distribution/getDistributionOrderList'
            , method: 'post'
            , contentType: 'application/json'
            , headers: {
                Authorization: localStorage.token
            }
            , response: {
                statusCode: 200 //规定成功的状态码，默认：0
            }
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": 200,
                    "count": res.data.recordsTotal, //解析数据长度
                    "data": res.data.data //解析数据列表
                };
            }
            ,request: {
                pageName: 'start' //页码的参数名称，默认：page
                ,limitName: 'length' //每页数据量的参数名，默认：limit
            }
            , cols: [[
                { field: 'orderNo', title: '订单编号' }
                , { field: 'distributionName', title: '商品名称' }
                , { field:"rank", title: '排名', width: 80, sort: true}
                , { field: 'bonusPoints', title: '初始级别增送积分' }
                , { field: 'bonusPresentation', title: '初始级别增送分红(元)' }
                , { field: 'currentBonus', title: '当前位置分红' }
                , { field: 'currentLevelBonusPoints', title: '当前级别增送积分' }
                , { field: 'currentLevelBonusPresentation', title: '当前级别增送分红(元)' }
                , { field: 'orderStatus', title: '订单状态',templet: function (res) {
                        return res.orderStatus == 30000 ? "已支付" :res.orderStatus == 20000?"待支付":'<span style="color: #f00;">'+ "已关单" +'</span>'
                    }}
                , { field: 'payType', title: '支付方式', templet: function (res) {
                        return res.payType == 1 ? "微信支付" : res.payType == 2 ? "支付宝支付" : res.payType == 3 ? "分红购买" : res.payType == 4 ? "超高级购买" : "-"
                    }}
                , {field: 'userName', title: '购买人姓名', templet: function (res) {
                        return res.userName ? res.userName : '-'
                    }}
                , {field: 'shareUserName', title: '邀请人姓名',templet: function (res) {
                        return res.shareUserName ? res.shareUserName : '-'
                    }}
                , { field: 'distributionOrderGoodsVo', title: '价格（元）', templet: function (res) {
                        return res.distributionOrderGoodsVo && res.distributionOrderGoodsVo.price ? res.distributionOrderGoodsVo.price : '-'
                    }}
                , { field:"createTime", title: '创建时间'}
                // , { title: '操作', toolbar: '#barDemo', width: 90 }
            ]],
            page: true
        });

        laydate.render({
            elem: '#test1'
            ,range: true
        });

        // 搜索
        form.on("submit(searchForm)", function(e){

            if (e.field.settleTimeStart) {
                var a = e.field.settleTimeStart.split(" - ");
                e.field.settleTimeStart = new Date(a[0]).getTime();
                e.field.settleTimeEnd = new Date(a[1]).getTime();
            }

            table.reload('fxOrderListTable', {
                page: {
                    start: 1 //重新从第 1 页开始
                }
                ,where: e.field
            });

            return false;
        })


        // 搜索
        form.on("submit(reset)", function(e){
            table.reload('fxOrderListTable', {
                page: {
                    start: 1 //重新从第 1 页开始
                }
                ,where: null
            });

            form.val("resets", {
                userName: "",
                orderNo: "",
                settleTimeStart: "",
                distributionName:""
            });

            return false;
        })


        // 筛选状态
        form.on("select(select)", function(e){
            table.reload('fxOrderListTable', {
                page: {
                    start: 1 //重新从第 1 页开始
                }
                ,where: {
                    orderStatus: e.value
                }
            });
        })

        // $("#exports").on("click", function(){
        //     ajax({
        //         path: "/distribution/export",
        //         type:"get",
        //         success: function (res) {
        //             console.log(res);
        //         }
        //     }, $)
        // })
    });
</script>

</html>